import type { Response } from '@/utils/type'
import request from '@/utils/request'
import type { MenuTree } from '@/api/back-management/menu/interface'

/**
 * 获取菜单目录树
 *
 * @param {any} params 查询参数
 */
export const queryMenuList = (params: any): Promise<Response<MenuTree[]>> => {
  return request('/resource/datacatalog/menu/query', {
    method: 'GET',
    params,
  })
}

/**
 * 新增菜单目录树
 *
 * @param {any} params 请求参数
 */
export const addMenuTree = (
  // params: object,
  data: any
): Promise<Response<MenuTree[]>> => {
  return request('/resource/datacatalog/menu/add', {
    method: 'POST',
    // params,
    data: data,
  })
}

/**
 * 修改菜单目录树
 *
 * @param {any} params 请求参数
 */
export const updateMenuTree = (
  // params: object,
  data: any
): Promise<Response<MenuTree[]>> => {
  return request('/resource/datacatalog/menu/add', {
    method: 'POST',
    // params,
    data: data,
  })
}

/**
 * 删除菜单目录
 *
 * @param {pkid} pkid 目录id
 */
export const deleteMenuTree = (pkid: string): Promise<Response<MenuTree[]>> => {
  return request(`/resource/datacatalog/delete?pkid=${pkid}`, {
    method: 'DELETE',
  })
}
